package com.zsk.shop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zsk.shop.entity.ShopCollection;
import com.zsk.shop.model.results.ShopContentListResults;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ShopCollectionMapper extends BaseMapper<ShopCollection> {
    int deleteByPrimaryKey(Long id);

    int insertSelective(ShopCollection record);

    ShopCollection selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(ShopCollection record);

    /**
     * 用户是否收藏
     * @param userNo
     * @param goodsNo
     * @param goodsOrderType
     * @return
     */
    @Select("SELECT COUNT(1) FROM shop_collection WHERE user_no=#{userNo} AND goods_no=#{goodsNo} AND goods_order_type=#{goodsOrderType}")
    int queryCollectionByContentNo(@Param("userNo") String userNo, @Param("goodsNo") String goodsNo, @Param("goodsOrderType") Integer goodsOrderType);

    /**
     * 收藏列表
     * @param userNo
     * @param page
     * @param limit
     * @return
     */
    List<ShopContentListResults> getUserCollectionList(@Param("userNo") String userNo, @Param("page") Integer page, @Param("limit") Integer limit);

    /**
     * 收藏数量
     * @param userNo
     * @return
     */
    int getUserCollectionCount(@Param("userNo") String userNo);


    /**
     * 取消收藏
     * @param userNo
     * @param goodsNo
     * @return
     */
    @Delete("DELETE FROM shop_collection WHERE user_no=#{userNo} AND goods_no=#{goodsNo} AND goods_order_type=#{goodsOrderType}")
    int deleteCollectionByUser(@Param("userNo") String userNo, @Param("goodsNo") String goodsNo, @Param("goodsOrderType") Integer goodsOrderType);
}